import Vue from 'vue'
import Router from 'vue-router'
import login from '@/page/login/login'
import auth from '@/page/login/auth'
import main from '@/page/main'
import managerlist from '@/page/manager/managerList'
import commodityList from '@/page/commodity/commodityList'
import addSku from '@/page/commodity/addCommoditySku'
import roleList from '@/page/role/roleList'
import commodityClassificationList from '@/page/commodity/commodityClassificationList'
import flashPromotionList from '@/page/flashpromotion/flashPromotionList'
import flashPromotionSessionList from '@/page/flashpromotion/flashPromotionSessionList'
import permissionsList from '@/page/permissions/permissionsList'
import {afterEach, beforeEach} from '../config/intercepters/router'

Vue.use(Router)

let router = new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'login',
      component: login
    },
    {
      path: '/auth',
      name: 'auth',
      component: auth
    },
    {
      path: '/main',
      name: 'main',
      component: main,
      children: [
        {
          path: '/manager/managerlist',
          name: 'managerlist',
          component: managerlist
        },
        {
          path: '/role/roleList',
          name: 'roleList',
          component: roleList
        },
        {
          path: '/commodity/commodityClassificationList',
          name: 'commodityClassificationList',
          component: commodityClassificationList
        },
        {
          path: '/commodity/commodityList',
          name: 'commodityList',
          component: commodityList
        },
        {
          path: '/commodity/:id/addSku',
          name: 'addSku',
          component: addSku
        },
        {
          path: '/flashPromotionList',
          name: 'flashPromotionList',
          component: flashPromotionList
        },
        {
          path: '/flashPromotionSessionList',
          name: 'flashPromotionSessionList',
          component: flashPromotionSessionList
        },
        {
          path: '/permissions/list',
          name: 'permissionsList',
          component: permissionsList
        }
      ]
    }
  ]
})

router.beforeEach(beforeEach)
router.afterEach(afterEach)

export default router
